<template>
  <footer>
    <ul>
      <router-link
        :to="{ path: item.url }"
        v-for="item in navList"
        :key="item.title"
        :class="{ active: active == item.title }"
        @click="handleClick(item)"
        tag="li"
      >
        <span class="iconfont" :class="item.icon"></span>
        <p>{{ item.title }}</p>
      </router-link>
    </ul>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      navList: [
        {
          title: "电影/影院",
          icon: "icon-dianying",
          url: "/home/movies",
        },
        {
          title: "视频",
          icon: "icon-shipin",
          url: "/home/video",
        },
        {
          title: "小视频",
          icon: "icon-shipin1",
          url: "/home/minivideo",
        },
        {
          title: "演出",
          icon: "icon-piaoquan",
          url: "/home/show",
        },
        {
          title: "我的",
          icon: "icon-wode",
          url: "/home/mine",
        },
      ],
      active: sessionStorage.getItem("active") || "电影/影院",
    };
  },
  // methods: {
  //   handleClick(item) {
  //     this.active = item.title;
  //     sessionStorage.setItem("active", this.active);
  //     this.$router.push(item.url);
  //   },
  // },
  // watch: {
  //   // 监听url的改变
  //   $route(val) {
  //     // console.log(val);
  //     this.navList.forEach((item) => {
  //       if (item.url === val.path) {
  //         this.active = item.title;
  //       }
  //     });
  //   },
  // },
};
</script>

<style lang="less" scoped>
@import "../../assets/css/var.less";

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  border-top: 1px solid @border-color;
  background: #fff;

  ul {
    width: 100%;
    height: 100%;
    display: flex;

    li {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-size: @s-font;

      p {
        margin-top: 5px;
        font-size: @xs-font;
      }
    }
    .iconfont {
      font-size: 18px;
    }
    .router-link-active {
      color: @theme-color;
    }
  }
}
</style>
